import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isPlay : true,
    url: '',
    id : '',
    upload:'/api/admin/common/upload',
    type :'off',
    musicTotalTime:'',
    currentTime:0,
    total:0,
    newCurrentTime:0,
    volume:0,
    musicImg:'https://web-photoss.oss-cn-beijing.aliyuncs.com/6f792527-5ef3-49dc-8f4a-d847342ade8b.jpg',
    singerName:'-未知',
    songName:'网易云音乐',
    listSong:[],
    openAsideList:false,
    musicIndex: "",
    mode:'loopOnce',
    logStatue : false,
    consumerId:'',
    consumerName:'未登录',
    consumerAvatar:'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
    consumerIsLogin:false,
    consumerMenu:false,
  },
  getters: {
    isPlay : state => state.isPlay,
    url : state =>{
      let url = state.url;
      if(!url){
        url = JSON.parse(window.sessionStorage.getItem('url')|| null);
      }
      return url;
    }
    ,
    id : state => state.id,
    upload : state => state.upload,
    type : state => state.type,
    musicTotalTime: state => state.musicTotalTime,
    currentTime: state => state.currentTime,
    total : state => state.total,
    newCurrentTime : state => state.newCurrentTime,
    volume : state => state.volume,
    musicImg : state => state.musicImg,
    singerName : state => state.singerName,
    songName : state => state.songName,
    listSong : state => state.listSong,
    openAsideList : state => state.openAsideList,
    musicIndex : state => state.musicIndex,
    mode :state => state.mode,
    logStatue : state => state.logStatue,
    consumerId : state => state.consumerId,
    consumerName : state => state.consumerName,
    consumerAvatar : state => state.consumerAvatar,
    consumerIsLogin : state => state.consumerIsLogin,
    consumerMenu : state => state.consumerMenu,
   


    
    
  },
  mutations: {
    setIsPlay :( state , isPlay) =>{state.isPlay  = isPlay},
    setUrl : (state , url) =>{ state.url = url},
    setId : (state , id) =>{ state.id = id},
    setType: (state , type) =>{ state.type = type}, 
    setMusicTotalTime: (state , musicTotalTime) =>{ state.musicTotalTime = musicTotalTime}, 
    setCurrentTime: (state , currentTime) =>{ state.currentTime = currentTime}, 
    setTotal: (state , total) =>{ state.total = total}, 
    setNewCurrentTime: (state , newCurrentTime) =>{ state.newCurrentTime = newCurrentTime}, 
    setVolume: (state , volume) =>{ state.volume = volume}, 
    setMusicImg: (state , musicImg) =>{ state.musicImg = musicImg}, 
    setSingerName: (state , singerName) =>{ state.singerName = singerName}, 
    setSongName: (state , songName) =>{ state.songName = songName}, 
    setListSong: (state , listSong) =>{ state.listSong = listSong}, 
    setOpenAsideList: (state , openAsideList) =>{ state.openAsideList = openAsideList}, 
    setMusicIndex: (state , musicIndex) =>{ state.musicIndex = musicIndex}, 
    setMode: (state , mode) =>{ state.mode = mode}, 
    setLogStatue: (state , logStatue) =>{ state.logStatue = logStatue}, 
    setConsumerId: (state , consumerId) =>{ state.consumerId = consumerId}, 
    setConsumerName: (state , consumerName) =>{ state.consumerName = consumerName}, 
    setConsumerAvatar: (state , consumerAvatar) =>{ state.consumerAvatar = consumerAvatar}, 
    setConsumerIsLogin: (state , consumerIsLogin) =>{ state.consumerIsLogin = consumerIsLogin}, 
    setConsumerMenu: (state , consumerMenu) =>{ state.consumerMenu = consumerMenu}, 
   
    
  },
  actions: {
  },
  modules: {
  }
})
